package com.lanou.stringsdt;

import java.util.Arrays;

public class StringADT {
	
	private String[] elements = new String[5];
	private int size = 0;
	public int length() {
		return size;
	}
	public void add(String entry) {
		if(size >= elements.length) {
			elements = Arrays.copyOf(elements, elements.length + 10);
		}
		elements[size] = entry;
		size++;
	}
	public void set(int index,String s) {
		if(index >= size && index < 0) {
			return;
		}
		elements[index] = s;
	}
	public void delete(int index) {
		if(index >= size || index < 0) {
			return;
		}
		String[] tempElement = new String[elements.length];
		int count = 0;
		for(int i = 0; i < elements.length; i++) {
			if(i == index) {
				continue;
			}
			tempElement[count] = elements[i];
			count++;
		}
		elements = tempElement;
		size--;
	}
	public void test() {
		System.out.println(Arrays.toString(elements));
	}

}
